/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.me.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Jayasundara
 */
@Entity
@Table(name = "Component", catalog = "postgres", schema = "public")
@NamedQueries({@NamedQuery(name = "Component.findAll", query = "SELECT c FROM Component c"), @NamedQuery(name = "Component.findById", query = "SELECT c FROM Component c WHERE c.id = :id"), @NamedQuery(name = "Component.findByName", query = "SELECT c FROM Component c WHERE c.name = :name"), @NamedQuery(name = "Component.findByDescription", query = "SELECT c FROM Component c WHERE c.description = :description")})
public class Component implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "name", length = 15)
    private String name;
    @Column(name = "description", length = 25)
    private String description;
    @OneToMany(mappedBy = "componentId")
    private List<Versions> versionsCollection;
    @OneToMany(mappedBy = "componentId")
    private List<Task> taskCollection;
    @JoinColumn(name = "project_id", referencedColumnName = "id")
    @ManyToOne
    private Project projectId;
    @JoinColumn(name = "component_lead", referencedColumnName = "id")
    @ManyToOne
    private User componentLead;

    public Component() {
    }

    public Component(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<Versions> getVersionsCollection() {
        return versionsCollection;
    }

    public void setVersionsCollection(List<Versions> versionsCollection) {
        this.versionsCollection = versionsCollection;
    }

    public List<Task> getTaskCollection() {
        return taskCollection;
    }

    public void setTaskCollection(List<Task> taskCollection) {
        this.taskCollection = taskCollection;
    }

    public Project getProjectId() {
        return projectId;
    }

    public void setProjectId(Project projectId) {
        this.projectId = projectId;
    }

    public User getComponentLead() {
        return componentLead;
    }

    public void setComponentLead(User componentLead) {
        this.componentLead = componentLead;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Component)) {
            return false;
        }
        Component other = (Component) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.me.entity.Component[id=" + id + "]";
    }

}
